import java.time.LocalDate;
import java.time.Month;
import javax.swing.*;  
import java.awt.*;  
import java.text.*;  
import java.util.*;  
public class clock implements Runnable{  
JFrame f;  
Thread t=null;  
int hours=0, minutes=0, seconds=0;  
String timeString = "";  
JLabel b;  
  
clock(){  
    f=new JFrame();  
    f.setTitle("Clock");
    Image icon = Toolkit.getDefaultToolkit().getImage("Apps-clock-icon.png");    
    f.setIconImage(icon);    
      
    t = new Thread(this);  
        t.start();  

    LocalDate currentdate = LocalDate.now();
    int currentDay = currentdate.getDayOfMonth();
    Month currentMonth = currentdate.getMonth();
    int currentYear = currentdate.getYear();

    JLabel l1= new JLabel("Clock");
    l1.setBounds(105,75,100,50);
    Font font = new Font("Arial", Font. BOLD,30);
    l1. setFont(font);

    b=new JLabel("");  
    b.setBounds(130,100,100,50); 
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
        
    JLabel l2= new JLabel("Date: " +currentDay +" OF " +currentMonth +" " +currentYear);
    l2.setBounds(85,120,400,50);
      
    f.add(b);  
    f.add(l1);
    f.add(l2);
    f.setSize(300,300);  
    f.setLayout(null);  
    f.setVisible(true);  
}  
  
 public void run() {  
      try {  
         while (true) {  
  
            Calendar cal = Calendar.getInstance();  
            hours = cal.get( Calendar.HOUR_OF_DAY );  
            if ( hours > 12 ) hours -= 12;  
            minutes = cal.get( Calendar.MINUTE );  
  
            SimpleDateFormat formatter = new SimpleDateFormat("hh:mm");  
            Date date = cal.getTime();  
            timeString = formatter.format( date );  
  
            printTime();  
  
            Thread.sleep( 1000 );  // interval given in milliseconds  
         }  
      }  
      catch (Exception e) { }  
 }  
  
public void printTime(){  
b.setText(timeString);  
}  
  
public static void main(String[] args) {  
    new clock();  
          
  
}  
}  